home *** CD-ROM | disk | FTP | other *** search
- /* TabbyLogger.c */
- /* This is based on a program that does nothing It is provided as an example or shell for making programs in */
- /* Think C that work with Tabby. Use it as you wish. Give credit for this to Kirk Crawford if */
- /* you wish. As of 6/3/92 this worked with Think C version 5.0.2. This is actually a cut */
- /* down version of TSort version 1.2. No warranties are expressed or implied. If this thing */
- /* screws up your computer, don't come to me. It's free, you get what you pay for, etc.... */
- /* Kirk Crawford, FidoNet Node 1:102/132 Insert a call to your subroutine in the lower portion */
- /* of main() Make sure you have the Set Project Type... stuff set the same.*/
- #include <String.h>
- #include <stdlib.h>
- int sprintf(unsigned char *dest, char *fmt, ...);
- int sscanf(unsigned char *dest, char *fmt, ...);
- #include "Main.p"
- #include <tabbyutils.h>
- #include <TabbyUtils.proto.h>
- #include "TabbyLogger.proto.h"
-
- /* #define _DEBUG_ */ /* for use when Debugging Generic Import file */
- #define VerDlgID 128 /* Resource ID of the Dialog Box */
-
- SysEnvRec gMac; /* info about the machine we are using */
- int MyvRefNum, /* four globals for the Tabby Utils file */
- MultiFinder; /* true when multifinder is running */
- Str255 BBSName, /* name of the BBS program or last ditch launch program */
- ProgName; /* name of this program */
- main()
- {
- DialogPtr VerDlg; /* something to show on the screen */
- VersRecHndl version;/* to find our version */
- Str255 VerStr, /* the version of this program */
- s; /* useful string */
- unsigned long sleep=10; /* how long to sleep when multifindering */
- int i; /* usefull int */
- EventRecord event; /* those useful events */
-
- /* initialize */
- strcpy(ProgName,(unsigned char *)"TabbyLogger"); /* set our program name */
- MaxApplZone(); /* get memory */
- MoreMasters(); /* get master pointers */
- InitGraf(&thePort); /* start QuickDraw */
- InitFonts(); /* Start the Fonts */
- InitWindows(); /* Start the Windows */
- InitMenus(); /* start the Menus */
- TEInit(); /* Start Text Edit */
- InitDialogs(nil); /* Start The Dialogs */
- SysEnvirons(2,&gMac); /* check out the macintosh */
- InitCursor(); /* Change to The Arrow Cursor */
- EventAvail(everyEvent, &event); /* so that we come up in the foreground in MF */
- EventAvail(everyEvent, &event);
- EventAvail(everyEvent, &event);
- FlushEvents(everyEvent,0); /* dump any leftover events */
- /* get the version */
- version = (VersRecHndl)GetResource('vers',1);
- if(!version){
- sprintf(VerStr,"UnKnown");
- } else {
- HLock(version);
- PtoCstr((char *)(**version).shortVersion);
- strcpy(VerStr,(unsigned char *)(**version).shortVersion);
- HUnlock(version);
- ReleaseResource(version);
- }
- /* get my local vRefNum */
- if(GetVol(s,&MyvRefNum))
- ExitToShell();
- /* log our starting */
- sprintf(s,"Program Starting, Version %s",VerStr);
- Log(s);
- /* show the dialog box */
- if((VerDlg = GetNewDialog(VerDlgID,nil,(WindowPtr)-1))){
- centerwindow(VerDlg,&screenBits.bounds);
- ShowWindow(VerDlg);
- DrawDialog(VerDlg);
- }
- MultiFinder = FALSE; /* set the default values */
- sprintf(BBSName,"Second Sight");
- CtoPstr(BBSName);
- GetTabbyConfigStuff(); /* get the real values */
- if(MultiFinder) /* let the last app die if it wants to */
- for(i=0; i<20; i++)
- WaitNextEvent(everyEvent, &event, sleep, nil);
-
- /***********************************/
- /* Insert your wonderful code here */
- /***********************************/
- DoIt();
- /*******************/
-
- Log((unsigned char *)"Program Ending"); /* log the Ending */
- if(VerDlg) /* kill the display */
- DisposDialog(VerDlg);
- LaunchNext(MyvRefNum); /* probably won't come back from this */
- ExitToShell(); /* exit to finder if we do */
- } /* that's all folks */
-
- /***********************************************************************************************/
- centerwindow(wind,r)
- WindowPtr wind;
- Rect *r;
- {
- Rect r2;
-
- r2 = wind->portRect;
- MoveWindow (wind,
- ((r->right-r->left)-(r2.right-r2.left))/2 - r->left,
- ((r->bottom-r->top)-(r2.bottom-r2.top))/2 - r->top,
- FALSE);
- }
-